import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
import UTILS from "common/src/utils/utils";
// 获取批次下拉数据
function getBatchNameList() {
  return fetch({
      url: `${baseUrl}/recommendRoster/getBatchNameList`,
      method: 'get'
  });
}
// 根据批次级联学院/部门下拉数据
function getDeptNameList(batchName) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getDeptNameList?batchName=${batchName}`,
      method: 'get'
  });
}
// 查询
function getRosterList(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getRosterList`,
      method: 'post',
      data
  });
}
// 根据id获取信息
function getRosterById(facultyId,approveType,role) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getRosterById?facultyId=${facultyId}&approveType=${approveType}&role=${role}`,
      method: 'get'
  });
}
// 批量下载
function downloadfile(data) {
  return fetch({
      url: `${baseUrl}/configOptions/downloadfile`,
      method: 'post',
      data
  });
}
// 批量导出
function exportRosterExcel(data) {
  return fetch({
      url: `${baseUrl}/configOptions/exportRosterExcel`,
      method: 'post',
      data
  });
}
// 学号模糊查询
function getStudent(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getStudent`,
      method: 'post',
      data
  });
}
// 根据学号查询学院专业等数据
function getStudentInformation(studentId) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getStudentInformation?studentId=${studentId}`,
      method: 'get'
  });
}
// 保存草稿状态
function saveRoster(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/saveRoster`,
      method: 'post',
      data
  });
}
// 推荐免试攻读研究生名额分配
function getBatchFacultyList(data) {
  return fetch({
      url: `${baseUrl}/recommendPostBatch/getBatchFacultyList`,
      method: 'post',
      data
  });
}
// 新增/编辑校验
function checkRoster(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/checkRoster`,
      method: 'post',
      data
  });
}
// 获取权限
// schoolAdmin 学校管理员
// principal 学院负责人
// acdemic 学院教务员
function recommendRole() {
  return fetch({
      url: `${baseUrl}/recommendRoster/recommendRole`,
      method: 'get' 
  });
}
// 审核列表接口（分页）
function getRosterStudentList(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getRosterStudentList`,
      method: 'post',
      data
  });
}
// 通过
function approveAgree(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/approveAgree`,
      method: 'post',
      data
  });
}
// 驳回
function approveRefuse(data) {
  return fetch({
      url: `${baseUrl}/recommendRoster/approveRefuse`,
      method: 'post',
      data
  });
}
// 工作流历史
function getApproveDetail(relationId) {
  return fetch({
      url: `${baseUrl}/recommendRoster/getApproveDetail?relationId=${relationId}`,
      method: 'get'
  });
}
// 驳回
function importGuaranteeList(data) {
  return fetch({
      url: `${baseUrl}//configOptions/importGuaranteeList`,
      method: 'post',
      data
  });
}
/**
* 获取key
*/
function exportStatus(key) {
  return fetch({
      url: `${baseUrl}/export/result/${key}`,
      method: 'get',
  });
}
// 下载模板
function downloadGuaranteeList() {
  let url = `${baseUrl}/configOptions/downloadGuaranteeList`;
  window.open(url);
}
// 批量下载附件前校验接口
function getIsExist(data) {
  return fetch({
      url: `${baseUrl}/newInfo/getIsExist`,
      method: 'post',
      data
  });
}

// 下载异步获取KEY
function batchExport(data) {
  return fetch({
      url: `${baseUrl}/configOptions/batchExport`,
      method: 'post',
      data
  });
}

// 下载异步
function exportConferenceT(data) {
  return fetch({
    url: `${baseUrl}/export/result/` + data,
    method: 'get',
    data
  });
}

// 批量下载附件3
function exportZip(data) {
  return fetch({
    url: `${baseUrl}/export/exportZip/?path=` + data,
    method: 'get',
    data,
    responseType: 'blob'
  }).then(res => {
    UTILS.downloadFile(res, '保研管理附件.zip', 'application/zip;charset=utf-8');
  });
}

const nameManageApi = {
  getBatchNameList,
  getDeptNameList,
  getRosterList,
  downloadfile,
  getRosterById,
  getStudent,
  getStudentInformation,
  saveRoster,
  getBatchFacultyList,
  checkRoster,
  recommendRole,
  getRosterStudentList,
  approveAgree,
  approveRefuse,
  getApproveDetail,
  exportRosterExcel,
  exportStatus,
  importGuaranteeList,
  downloadGuaranteeList,
  getIsExist,
  batchExport,
  exportConferenceT,
  exportZip
  
}
export default nameManageApi;
